package com.erb.controller.ljy;

import com.erb.entity.Pager;
import com.erb.entity.User;
import com.erb.service.ljy.capitalLogService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * ClassName: capitallogController
 * Description: 个人中心的资金记录
 * date: 2020/6/10 9:23
 *
 * @author JY
 */

@Controller
@RequestMapping("/cap")
public class capitallogController {


	@Resource
	private capitalLogService logService;

	//去资金记录
	@RequestMapping("/cap_List")
	public String capitalList(Pager pager, Integer type, String tradeDate, String lx, Model model, HttpSession session) {
		User user = (User) session.getAttribute("user");
		model.addAttribute("types", type);  //传给页面选中下拉框
		model.addAttribute("lx", lx);  //传给页面选中下拉框
		model.addAttribute("date", tradeDate);  //给分页按钮
		//更改每页显示行数
		pager.pageSize = 5;
		//查询总行数
		Integer i = logService.countselcap(user.getId(), type, tradeDate);
		pager.page(i);
		model.addAttribute("size", i);
		//把定义的数据传到data，然后直接model发布。【因为data也是pager中的一个属性】
		pager.data = logService.pageselcap(pager, user.getId(), type, tradeDate);
		model.addAttribute("cap", pager);
		return "personal/capitalList";
	}

}
